﻿using System;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YJKRevitView;

namespace YJKRevitAxisModule
{
	[Regeneration(RegenerationOption.Manual)]
	[Transaction(TransactionMode.Manual)]
	public class CmdRectAxisCreate : YJKCommandManual
	{
		protected override Result YJKExcute(ExternalCommandData cmdData, ref string message, ElementSet elements)
		{
			CmdViewType types = (CmdViewType)11;
			if (SwitchView.SetUsableView(types, cmdData) != Autodesk.Revit.UI.Result.Succeeded)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			using (RectAxisForm rectAxisForm = new RectAxisForm(cmdData))
			{
				DialogResult dialogResult = rectAxisForm.ShowDialog();
				if (dialogResult == DialogResult.Cancel)
				{
					return Autodesk.Revit.UI.Result.Cancelled;
				}
				if (dialogResult == DialogResult.OK)
				{
					return new RectAxisCreator(cmdData, this.m_uiApp, rectAxisForm.m_dataFromDlg).CreateAxis(ref message, this.m_doc);
				}
			}
			return base.YJKExcute(cmdData, ref message, elements);
		}
	}
}
